﻿using System;

namespace UniRx.Operators
{
	// Token: 0x020002CB RID: 715
	public abstract class OperatorObservableBase<T> : IObservable<T>, IOptimizedObservable<T>
	{
		// Token: 0x06000F67 RID: 3943 RVA: 0x0003F8FF File Offset: 0x0003DCFF
		public OperatorObservableBase(bool isRequiredSubscribeOnCurrentThread)
		{
			this.isRequiredSubscribeOnCurrentThread = isRequiredSubscribeOnCurrentThread;
		}

		// Token: 0x06000F68 RID: 3944 RVA: 0x0003F90E File Offset: 0x0003DD0E
		public bool IsRequiredSubscribeOnCurrentThread()
		{
			return this.isRequiredSubscribeOnCurrentThread;
		}

		// Token: 0x06000F69 RID: 3945 RVA: 0x0003F918 File Offset: 0x0003DD18
		public IDisposable Subscribe(IObserver<T> observer)
		{
			SingleAssignmentDisposable subscription = new SingleAssignmentDisposable();
			if (this.isRequiredSubscribeOnCurrentThread && Scheduler.IsCurrentThreadSchedulerScheduleRequired)
			{
				Scheduler.CurrentThread.Schedule(delegate()
				{
					subscription.Disposable = this.SubscribeCore(observer, subscription);
				});
			}
			else
			{
				subscription.Disposable = this.SubscribeCore(observer, subscription);
			}
			return subscription;
		}

		// Token: 0x06000F6A RID: 3946
		protected abstract IDisposable SubscribeCore(IObserver<T> observer, IDisposable cancel);

		// Token: 0x040008F7 RID: 2295
		private readonly bool isRequiredSubscribeOnCurrentThread;
	}
}
